<!doctype html>
<html>
    <head>
<link rel="stylesheet" href="static/css/themes/suishoupai.css" />
  <link rel="stylesheet" href="static/css/themes/suishoupai.min.css" /> 
 <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile.structure-1.4.5.min.css" /> 
  <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> 
  <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> 
<meta charset="utf-8">
<title>图片上传返回</title>
    <style>
    body {
	margin: 0;
	/*width: 100%;
	height: 100%;*/
	background: #FF80AA url(../../../xiaohuikuaibang/background.jpg);
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none; /* 阻止浏览器选择文字 */
}
body, input, button, select {
	font: 16px/1.5em Helvetica, '微软雅黑', 'Microsoft Yahei Font', '文泉驿微米黑', 'WenQuanYi Micro Hei';
	font-weight: 400;
            color:white;
}
        .button {
	border: 2px solid #9580FF;
	text-align: center;
	width: 100%;
	height: 45px;
	font-size: 1.35em;
	position: absolute;
	box-sizing: border-box;
	left: 0px;
	font-family: '微软雅黑 Light';
}
.button-add {
	background: #9580FF;
	top: 10px;
}
        .entry {
	position: absolute;
	bottom: 10%;
	left: 20%;
	width: 60%;
            height: 120px;}
        .ss{
            position:absolute;
            top:30%;
            left:20%;
            width:60%;}
        .s{
            text-align: center;
            font-family: '微软雅黑 Light';
            font-size: 1.35em;}
    </style>
    
</head>

<body>
    
   
     
 <?php
 
 
$domain = "picture";
$upload_dir = "saestor://" . $domain . "/suishoupai/";
 
if(!is_dir($upload_dir))
{
 //mkdir($upload_dir , 0777);
}
 
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br />";
  }
else
  {
   echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  echo "Type: " . $_FILES["file"]["type"] . "<br />";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
  echo "Stored in: " . $_FILES["file"]["tmp_name"];
}
if(move_uploaded_file($_FILES["file"]["tmp_name"],$upload_dir . $_FILES["file"]['name']))
{
    $add="http://whdxxshxcb-picture.stor.sinaapp.com/suishoupai/" . $_FILES["file"]['name'];
}
// 连主库
$link=mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
// 连从库
// $link=mysql_connect(SAE_MYSQL_HOST_S.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);

if($link)
{
    mysql_select_db(SAE_MYSQL_DB,$link);
    //your code goes here
  $time=date('Y-m-d H:i:s'); 
    $sql="INSERT INTO suishoupai   (pic,name,time) VALUES ('$add','$_POST[name]','$time')";

if (!mysql_query($sql,$link))
  {
  die('Error: ' . mysql_error());
  }
    // echo "=<div class='ss'><a class='s'>提交成功!</a></div>";

mysql_close($link);
}
?>
    <div class="entry"><a href="http://whdxxshxcb.sinaapp.com/suishoupai/"><input type="button" class="button button-add" value="返回"></input></a></div>
</body>
   
</html>
